<?php

$blog_link = $blog->GetCatList($blogid, 'ee_blog_link');
$title = "添加blog链接";
$url = 'index.php?Action=LinkManage';

if($_GET['LinkId'])
{
	$Linkinfo = $blog->getInfo($_GET['LinkId'], 'ee_blog_link');
	if(!$Linkinfo)
	{
		echo "该blog链接不存在!";
		exit();
	}
	$title = "编辑blog链接";
	$url = "index.php?Action=LinkManage&LinkId={$_GET['LinkId']}";
}
if($_SERVER['REQUEST_METHOD']=='POST')
{
	$data = array();
	$data['F_ID_BLOG_INFO'] = $blogid;
	$data['F_BLOG_USER'] = $_POST['bloger'];
	$data['F_BLOG_Name'] = $_POST['blog-name'];
	$data['F_BLOG_LINK'] = $_POST['blog-link'];
	if($_GET['LinkId'])
	{
		$blog->updateData('ee_blog_link',$_GET['LinkId'],$data);
		echo "<script type=\"text/javascript\">";
	    echo "window.location='index.php?Action=LinkManage';";
	    echo "</script>";
		exit();
	}else{
		$blog->insertData('ee_blog_link',$data);
		echo "<script type=\"text/javascript\">";
	    echo "window.location='index.php?Action=LinkManage';";
	    echo "</script>";
		exit();
	}
}

?></div>
<div id="content"><div class="admin-form">
<h3>blog链接列表</h3>
<table>
<thead>
	<tr>
	    <th>链接ID</th>
	    <th>blog主人</th>
	    <th>blog名称</th>
	    <th>blog地址</th>
	    <th colspan="2">操作</th>
    </tr>
</thead>
<tbody>
<?php
foreach($blog_link as $linkNote)
{
?>
	<tr>
		<td><?php echo $linkNote['F_ID'] ?></td>
		<td><?php echo $linkNote['F_BLOG_USER'] ?></td>
		<td><?php echo $linkNote['F_BLOG_Name'] ?></td>
		<td><?php echo $linkNote['F_BLOG_LINK'] ?></td>
		<td><a href="index.php?LinkId=<?php echo $linkNote['F_ID'] ?>&Action=LinkManage">编辑</a></td>
		<td><a href="index.php?LinkId=<?php echo $linkNote['F_ID'] ?>&Action=LinkManageDel" onclick="javascript:confirm('真的要删除吗?')">删除</a></td>
	</tr>
<?php
}
?>
</tbody>
</table>

<form action="<?php echo $url ?>" method="post">
<fieldset>
	<legend><?php echo $title ?>表单</legend>
	<dl>
		<dt>blog主人：</dt>
		<dd><input type="text" name="bloger" value="<?php echo $Linkinfo['F_BLOG_USER'] ?>"></dd>
	</dl>
	<dl>
		<dt>blog名称：</dt>
		<dd><input type="text" name="blog-name" value="<?php echo $Linkinfo['F_BLOG_Name'] ?>"></dd>
	</dl>
	<dl>
		<dt>blog链接：</dt>
		<dd><input type="text" name="blog-link" value="<?php echo $Linkinfo['F_BLOG_LINK'] ?>"></dd>
	</dl>
	<dl>
		<dd class="submit-button"><input type="submit" name="submit" value="<?php echo $title?>"></dd>
	</dl>
</fieldset>
</form></div></div>